/**
 * Created by panjun7@yunzongnet.com on 2017/05/08.
 */
VoucherUseInstructionsController = function () {
    this.initPage = function(isBack) {
        this.voucherUseInstructions = CommonUtil.takeOutParamObject().voucherUseInstructions;
        if(!this.voucherUseInstructions){
        	this.voucherUseInstructions = ["本代金券不可兑换现金，不可找零。",""];
        }else if(this.voucherUseInstructions.length == 1 && this.voucherUseInstructions[0] == '本代金券不可兑换现金，不可找零。'){
        	this.voucherUseInstructions.push("");
        }

        CommonUtil.render($("#voucherUseInstructionsPage .content-wrap"), "voucherUseInstructionsTPL",{"voucherUseInstructions":this.voucherUseInstructions});
    };

    this.validateVoucherUseInstructions = function(){
    	var validationResult = {"success":true,"errorMsgs":[]};
    	this.voucherUseInstructions = [];
    	var self = this;
    	$(".input-wrap li input").each(function(i,n){
    		var useInstruction = $.trim($(n).val()).substring(0,100);
    		if(useInstruction.length>0){
    			self.voucherUseInstructions.push(useInstruction);
    		}
    	});

    	return validationResult;
    }
};